package com.ziyun.pop.modules.mercharReport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ziyun.pop.modules.mercharReport.dao.ReportStoreMemberDao;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreMemberVO;
import com.ziyun.pop.modules.mercharReport.entity.StoreMemberEntity;
import com.ziyun.pop.modules.mercharReport.service.ReportStoreMemberService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("reportStoreMemberService")
public class ReportStoreMemberServiceImpl extends ServiceImpl<ReportStoreMemberDao, StoreMemberEntity> implements ReportStoreMemberService {

    @Autowired
    private ReportStoreMemberDao reportStoreMemberDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<StoreMemberEntity> page = (Page<StoreMemberEntity>) this.page(
                new Query<StoreMemberEntity>(params).getPage(),
                new QueryWrapper<StoreMemberEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R list(Map<String, Object> params) {
        Page<ReportStoreMemberVO> page = new Page<>();
        page.setCurrent(Integer.valueOf(params.get("page").toString()));
        page.setSize(Integer.valueOf(params.get("limit").toString()));
        List<ReportStoreMemberVO> list = reportStoreMemberDao.list(page, params);
        page.setRecords(list);
        PageUtils pageUtils = new PageUtils(page);
        return R.ok().put("page", pageUtils);
    }

    @Override
    public List<ReportStoreMemberVO> exportExcel(Map<String, Object> params) {
        return reportStoreMemberDao.list(params);
    }

}
